/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#include "com_util.h"
#include <win32/win32.h>

namespace libcom
{

const String guid_to_string(const GUID & guid)
{
	//guid string length is always 39 characters without trailing zero
	const int guid_size = 39;
	wchar_t wstr[guid_size + 1];
	StringFromGUID2(guid, wstr, guid_size);
	wstr[guid_size] = L'\0';

	//If anybody knows how to use converter to convert WString to String,
	//please, rewrite the following code ;)
	char str[guid_size + 1];
	WideCharToMultiByte(CP_ACP, 0, wstr, guid_size, str, guid_size, 0, 0);
	str[guid_size] = '\0';
	return String(str);
}

}//end of namespace

